Make selecting the last character work again
authorMatthias Clasen <mclasen@redhat.com>
Fri, 9 Oct 2009 05:08:54 +0000 (07:08 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 9 Oct 2009 05:08:54 +0000 (07:08 +0200)
This broke when I added link support. git bisect helped to track it
down.

gtk/gtklabel.c

index 4577eec3b13fefb3bb65521e07404800f925fa4c..acf7f53bfad024e5b1b16b07aa545c108918ac2c 100644 (file)
@@ -3841,6 +3841,7 @@ get_layout_index (GtkLabel *label,
   gint trailing = 0;
   const gchar *cluster;
   const gchar *cluster_end;
+  gboolean inside;
 
   *index = 0;
 
@@ -3851,24 +3852,21 @@ get_layout_index (GtkLabel *label,
   x *= PANGO_SCALE;
   y *= PANGO_SCALE;
 
-  if (pango_layout_xy_to_index (label->layout,
-                                x, y,
-                                index, &trailing))
-    {
-      cluster = label->text + *index;
-      cluster_end = cluster;
-      while (trailing)
-        {
-          cluster_end = g_utf8_next_char (cluster_end);
-          --trailing;
-        }
-
-      *index += (cluster_end - cluster);
+  inside = pango_layout_xy_to_index (label->layout,
+                                     x, y,
+                                     index, &trailing);
 
-      return TRUE;
+  cluster = label->text + *index;
+  cluster_end = cluster;
+  while (trailing)
+    {
+      cluster_end = g_utf8_next_char (cluster_end);
+      --trailing;
     }
 
-  return FALSE;
+  *index += (cluster_end - cluster);
+
+  return inside;
 }
 
 static void